package com.itc.api.response.exception;

import lombok.Getter;
import lombok.ToString;
import org.springframework.http.HttpStatus;


/**
 * 业务异常信息的描述
 *
 * @author WY
 * @date 2023/06/26 14:05:07
 */
@ToString
@Getter
public enum ResultStatus {

    /**
     * 成功
     */
    SUCCESS(HttpStatus.OK, 0, "OK"),

    /**
     * 失败
     */
    FAIL(HttpStatus.OK, 1, "ERROR"),

    /**
     * 坏的请求
     */
    BAD_REQUEST(HttpStatus.BAD_REQUEST, 400, "Bad Request"),
    /**
     * 内部服务器错误
     */
    INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "Internal Server Error"),
    /**
     * 请求超时
     */
    REQUEST_TIMEOUT(HttpStatus.REQUEST_TIMEOUT, 408, "服务访问超时，请稍后再试"),
    /**
     * 被禁止的
     */
    FORBIDDEN(HttpStatus.FORBIDDEN, 403, "黑名单限制，禁止访问"),
    /**
     * 太多的请求
     */
    TOO_MANY_REQUESTS(HttpStatus.TOO_MANY_REQUESTS, 429, "访问频率超限，请稍后再试"),
    /**
     * 未经授权的
     */
    UNAUTHORIZED(HttpStatus.UNAUTHORIZED, 401, "认证失败，api-token错误"),
    /**
     * 重复处理
     */
    REPROCESSING(HttpStatus.TOO_MANY_REQUESTS, 1, "请勿重复提交"),
    /**
     * 参数有误
     */
    ERROR_PARAM(HttpStatus.BAD_REQUEST, 400, "参数有误");

    /**
     * 返回的HTTP状态码,  符合http请求
     */
    private final HttpStatus httpStatus;
    /**
     * 业务异常码
     */
    private final Integer code;
    /**
     * 业务异常信息描述
     */
    private final String message;

    ResultStatus(HttpStatus httpStatus, Integer code, String message) {
        this.httpStatus = httpStatus;
        this.code = code;
        this.message = message;
    }
}
